/**
 * 漆水河 脚手架基础公开课
 * 2022/8/13 --- 2022/12/13
 * 有疑问可加QQ群: 809126489，后续会持续输出与大家一起成长
 */
package com.qishuihe.common.application.role;

import com.qishuihe.basedomain.infrastructure.aspect.LogAnnotation;
import com.qishuihe.baseinterface.basevo.vo.ResultPageVO;
import com.qishuihe.baseinterface.basevo.vo.ResultVO;
import com.qishuihe.common.domain.role.service.PermissionService;
import com.qishuihe.common.domain.role.service.RolePermissionRelationService;
import com.qishuihe.common.domain.role.service.RoleService;
import com.qishuihe.outbound.role.IRole;
import com.qishuihe.outbound.user.PermissionDTO;
import com.qishuihe.outbound.user.QueryPageDTO;
import com.qishuihe.outbound.user.RoleDTO;
import com.qishuihe.outbound.user.RolePermissionDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/admin")
public class RoleControl implements IRole {

    @Autowired
    private RolePermissionRelationService rolePermissionRelationServiceImpl;

    @Autowired
    private PermissionService permissionServiceImpl;

    @Autowired
    private RoleService roleServiceImpl;

    @Override
    @PostMapping("/queryRole")
    @LogAnnotation
    public ResultPageVO<RoleDTO> queryRole(@RequestBody QueryPageDTO<RoleDTO> roleDTO) {
        return roleServiceImpl.queryRole(roleDTO);
    }

    @Override
    @PostMapping("/queryPermission")
    @LogAnnotation
    public ResultPageVO<PermissionDTO> queryPermission(@RequestBody QueryPageDTO<PermissionDTO> permissionDTO) {
        return permissionServiceImpl.queryPermission(permissionDTO);
    }

    @Override
    @PostMapping("/modfiyRole")
    @LogAnnotation
    public ResultVO<RoleDTO> modfiyRole(@RequestBody RoleDTO roleDTO) {

        return roleServiceImpl.modifyRole(roleDTO);
    }


    @PostMapping("/modfiyRolePermission")
    @Override
    @LogAnnotation
    public ResultVO<RolePermissionDTO> modfiyRolePermission(@RequestBody RolePermissionDTO rolePermissionDTO) {
        return rolePermissionRelationServiceImpl.modfiyRolePermission(rolePermissionDTO);
    }


    @Override
    public ResultVO<RoleDTO> queryRoleById() {
        return null;
    }

    @Override
    public ResultVO<String> deletRoleById(List<Long> ids) {
        return null;
    }
}
